﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;

using Kwan.Data;
using BG.Data;

namespace BG.Service
{
    public class ProductQuery
	{

		public static Expression MakeSearchWhere(NameValueCollection ps)
		{
			Expression exp = new Expression();

            string propName = "EntityID";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TProduct.entityID == int.Parse(ps[propName]);

			propName = "cid";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
				exp &= TProduct.cid == int.Parse(ps[propName]);
			}
			propName = "nameCN";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
				exp &= TProduct.nameCN == ps[propName];
			}
            propName = "price";
			if (!string.IsNullOrEmpty(ps[propName]))
			{
				exp &= TProduct.price == int.Parse(ps[propName]);
			}

			return exp;
		}
	}
}